package com.enation.app.javashop.core.client.fallback.member;

import com.enation.app.javashop.core.client.feignimpl.member.MemberCommentClientImpl;
import com.enation.app.javashop.core.handler.BaseFallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.enation.app.javashop.model.member.vo.GoodsGrade;
import com.enation.app.javashop.model.trade.order.dto.OrderDetailDTO;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 *会员评论相关熔断 fallback factory
 * @author kingapex
 * @version 1.0
 * @data 2022/5/28 14:25
 **/
@Component
public class MemberCommentClientFallbackFactory extends BaseFallbackFactory<MemberCommentClientImpl> {
    @Override
    protected MemberCommentClientImpl fallback() {
        return new MemberCommentClientFallback();
    }

    /**
     * 会员评论相关熔断
     *
     * @author zh
     * @version v7.0
     * @date 18/9/27 下午4:01
     * @since v7.0
     */
    @Component
    public static class MemberCommentClientFallback implements MemberCommentClientImpl {
        private final Logger logger = LoggerFactory.getLogger(getClass());

        @Override
        public void editComment(Long memberId, String face) {
            logger.error("修改评论失败");
        }

        @Override
        public List<GoodsGrade> queryGoodsGrade() {
            logger.error("获取商品的好评率错误");
            return null;
        }

        @Override
        public Integer getGoodsCommentCount(Long goodsId) {
            logger.error("根据商品id为" + goodsId + "获取评论数");
            return null;
        }

        @Override
        public void autoGoodComments(List<OrderDetailDTO> detailDTOList) {
            logger.error("自动好评错误");

        }
    }
}
